package rad.framework.mda.generator.template.main.webapp;

import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.*;
import java.util.*;
import rad.framework.mda.generator.util.*;

public class ViewKeys
{
  protected static String nl;
  public static synchronized ViewKeys create(String lineSeparator)
  {
    nl = lineSeparator;
    ViewKeys result = new ViewKeys();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<ui:composition " + NL + "\txmlns=\"http://www.w3.org/1999/xhtml\"" + NL + "\txmlns:ui=\"http://java.sun.com/jsf/facelets\"" + NL + "\txmlns:tt=\"https://code.google.com/p/rad-framework\">" + NL + "\t" + NL + "\t<tt:attributes>" + NL + "\t" + NL + "\t<ui:remove>";
  protected final String TEXT_2 = NL + "\t</ui:remove>" + NL;
  protected final String TEXT_3 = NL + "\t\t<tt:output type=\"";
  protected final String TEXT_4 = "\" id=\"";
  protected final String TEXT_5 = "\" " + NL + "\t\t\tvalue=\"#{entity.";
  protected final String TEXT_6 = "}\"" + NL + "\t\t\tlabel=\"#{messages['";
  protected final String TEXT_7 = "_";
  protected final String TEXT_8 = "']}\"" + NL + "\t\t\ttitle=\"#{messages['";
  protected final String TEXT_9 = "_";
  protected final String TEXT_10 = "Doc']}\"\t/>";
  protected final String TEXT_11 = NL + NL + "\t<ui:remove>";
  protected final String TEXT_12 = NL + "\t</ui:remove>" + NL + "\t\t" + NL + "\t</tt:attributes>" + NL + "" + NL + "</ui:composition>";
  protected final String TEXT_13 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Class uml2Class = (Class) argument;
    stringBuffer.append(TEXT_1);
    for (Iterator<Property> i=ClassHelper.getAllSimpleProperties(uml2Class); i.hasNext();) { Property property = i.next();
    String propertyName = NameHelper.uncapSafeName(property);
    if ("name".equals(propertyName) || "code".equals(propertyName)) {
    stringBuffer.append(TEXT_2);
    }
    stringBuffer.append(TEXT_3);
    stringBuffer.append(JsfHelper.getType(property));
    stringBuffer.append(TEXT_4);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_5);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(uml2Class.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_8);
    stringBuffer.append(uml2Class.getName());
    stringBuffer.append(TEXT_9);
    stringBuffer.append(property.getName());
    stringBuffer.append(TEXT_10);
    if ("name".equals(propertyName) || "code".equals(propertyName)) {
    stringBuffer.append(TEXT_11);
    }
    }
    stringBuffer.append(TEXT_12);
    stringBuffer.append(TEXT_13);
    return stringBuffer.toString();
  }
}
